package org.wangchaocheng.cloudgallery.user;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.wangchaocheng.cloudgallery.api.user.UserServiceI;
import org.wangchaocheng.cloudgallery.commond.user.UserModifyCmd;
import org.wangchaocheng.cloudgallery.commond.user.UserRegisterCmd;
import org.wangchaocheng.cloudgallery.commond.user.UserRoleSaveCmd;
import org.wangchaocheng.cloudgallery.dto.common.PageDTO;
import org.wangchaocheng.cloudgallery.dto.user.UserDTO;
import org.wangchaocheng.cloudgallery.query.user.UserPageQry;
import org.wangchaocheng.cloudgallery.user.executor.command.UserModifyCmdExe;
import org.wangchaocheng.cloudgallery.user.executor.command.UserRegisterCmdExe;
import org.wangchaocheng.cloudgallery.user.executor.command.UserRoleSaveCmdExe;
import org.wangchaocheng.cloudgallery.user.executor.query.UserPageQryExe;
import org.wangchaocheng.cloudgallery.user.executor.query.UserQryExe;

/**
 * @author wangchaocheng
 * @date 2025-03-01 10:30:19
 */
@Service
@RequiredArgsConstructor
public class UserServiceImpl implements UserServiceI {

    private final UserQryExe userQryExe;

    private final UserPageQryExe userPageQryExe;

    private final UserModifyCmdExe userModifyCmdExe;

    private final UserRegisterCmdExe userRegisterCmdExe;

    private final UserRoleSaveCmdExe userRoleSaveCmdExe;

    @Override
    public void register(UserRegisterCmd cmd) {
        userRegisterCmdExe.execute(cmd);
    }

    @Override
    public void modify(UserModifyCmd cmd) {
        userModifyCmdExe.execute(cmd);
    }

    @Override
    public UserDTO findById(Long userId) {
        return userQryExe.execute(userId);
    }

    @Override
    public UserDTO findByUsername(String username) {
        return userQryExe.execute(username);
    }

    @Override
    public PageDTO<UserDTO> listPageUser(UserPageQry qry) {
        return userPageQryExe.execute(qry);
    }

    @Override
    public void assignUserRoles(UserRoleSaveCmd userRoleSaveCmd) {
        userRoleSaveCmdExe.execute(userRoleSaveCmd);
    }

}
